<!DOCTYPE html>
<html lang="en">
<head>
    <title>佳怡供应链金融</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">

    <meta name="description" content="Write an awesome description for your new site here. You can edit this line in _config.yml. It will appear in your document head meta (for Google search results) and in your feed.xml site description.
">

    <!-- <link rel="stylesheet" href="../lib/weui.min.css">
     <link rel="stylesheet" href="../css/jquery-weui.css">
     <link rel="stylesheet" href="css/demos.css">-->
    <link rel="stylesheet" href="lib/weui.min.css">
    <link rel="stylesheet" href="css/jquery-weui.css">
    <link rel="stylesheet" href="demos/css/demos.css">
    <link rel="stylesheet" href="font/fontscss/iconfont.css">
    <link rel="stylesheet" href="css/common.css">
    <style type="text/css">
        .icon_back{
            position: absolute;
            left: -1rem;
            top: 0.9rem;
            width: 0.5rem;
            height: 1.0rem;
            background: url(./images/icon-back.png);
            background-size: 0.5rem 1em;
            vertical-align: middle;
        }

    </style>
</head>
<body>
<header>
    <div class="weui-row weui-no-gutter">
        <div class="weui-col-33" id="back_icon">
            <a href="javascript:history.go(-1)" class="icon pull-right"><i class="icon_back"></i></a>
        </div>
        <div class="weui-col-33">个人信息</div>
        <div class="weui-col-33">
        </div>
    </div>
</header>
<div class="weui-cells">

    <input type="hidden" id="imgs" name="imgs"/>
    <input type="hidden" id="imgsname" name="imgsname"/>
    <div class="weui-btn-area">
        <a href="javascript:;" onclick="loginout()" class="weui-btn weui-btn_warn">退出登录</a>
    </div>

</div>
<script src="lib/jquery-2.1.4.js"></script>
<script src='js/jquery-weui.js'></script>
<script src="js/reg.js"></script>
<script src="js/lrz.mobile.min.js"></script>

<script>
    $(function () {
        $.ajax({
            type: "POST",
            url: "login/getUserInfo",
            async: false,
            data: {id:localStorage.getItem("token")},
            success: function (msg) {
                console.info(msg);
                var str="";
                str+="<div class=\'weui-cell\'>"
                str+="                    <div class=\'weui-cell__bd\'>"
                str+="                    <p>会员姓名</p>"
                str+="                    </div>"
                str+="                    <div class=\'weui-cell__ft\'>"+isNull(msg.realname)+""
                str+="                    </div>"
                str+="                    </div>"
                str+="                    <div class=\'weui-cell\'>"
                str+="                    <div class=\'weui-cell__bd\'>"
                str+="                    <p>联系电话</p>"
                str+="                    </div>"
                str+="                    <div class=\'weui-cell__ft\'>"
                +msg.phone+""
                str+="                    </div>"
                str+="                    </div>"
                str+="                    <div class=\'weui-cell\'>"
                str+="                    <div class=\'weui-cell__bd\'>"
                str+="                    <p>所属事业部</p>"
                str+="                    </div>"
                str+="                    <div class=\'weui-cell__ft\'>"
                    +msg.department_name+""
                str+="                    </div>"
                str+="                    </div>"
                str+="                    <div class=\'weui-cell\'>"
                str+="                    <div class=\'weui-cell__bd\'>"
                str+="                    <p>所属中心</p>"
                str+="                    </div>"
                str+="                    <div class=\'weui-cell__ft\'>"
                +isNull(msg.department_name1)+""
                str+="                    </div>"
                str+="                    </div>"
                str+="                    <div class=\'weui-cell\'>"
                str+="                    <div class=\'weui-cell__bd\'>"
                str+="                    <p>所属项目部</p>"
                str+="                    </div>"
                str+="                    <div class=\'weui-cell__ft\'>"
                    +isNull(msg.department_name2)+""
                str+="                    </div>"
                str+="                    </div>"
                str+="                    <div class=\'weui-cell\'>"
                str+="                    <div class=\'weui-cell__bd\'>"
                str+="                    <p>邮箱</p>"
                str+="                    </div>"
                str+="                    <div class=\'weui-cell__ft\'>"
                +msg.mailbox+""
                str+="                    </div>"
                str+="                    </div>"
                str+="                    <div class=\'weui-cell\'>"
                str+="                    <div class=\'weui-cell__bd\'>"
                str+="                    <p>地址</p>"
                str+="                    </div>"
                str+="                    <div class=\'weui-cell__ft\'>"
                +msg.address+""
                str+="                    </div>"
                str+="                    </div>"
                str+="                    <div class=\'weui-cell\'>"
                str+="                    <div class=\'weui-cell__bd\'>"
                str+="                    <p>开户行</p>"
                str+="                    </div>"
                str+="                    <div class=\'weui-cell__ft\'>"
                +msg.bank_account+""
                str+="                    </div>"
                str+="                    </div>"
                str+="                    <div class=\'weui-cell\'>"
                str+="                    <div class=\'weui-cell__bd\'>"
                str+="                    <p>账号</p>"
                str+="                    </div>"
                str+="                    <div class=\'weui-cell__ft\'>"
                    +msg.account_number+""
                str+="                    </div>"
                str+="                    </div>"
                str+="                    <div class=\'weui-cell\'>"
                str+="                    <div class=\'weui-cell__bd\'>"
                str+="                    <p>户名</p>"
                str+="                    </div>"
                str+="                    <div class=\'weui-cell__ft\'>"
                    +msg.account_name+""
                str+="                    </div>"
                str+="                    </div>"
             /*   str+="                    <div class=\'weui-cell\'>"
                str+="                    <div class=\'weui-cell__bd\'>"
                str+="                    <p>上传头像</p>"
                str+="                    </div>"
                str+="                    <div class=\'weui-cell__ft\'>"
                str+="                    </div>"
                str+="                    </div>"*/
                str+="   <div id='img' >"
                str+="   <div class='weui-cell'>"
                str+="   <div class='weui-cell__bd'>"
                str+="    <div class='weui-uploader'>"
                str+="    <div class='weui-uploader__hd'>"
                str+="    <p class='weui-uploader__title'>上传头像</p>"
                str+="   </div>"


                str+="   <div class='weui-uploader__bd'>"
                str+="   <ul class='weui-uploader__files' id='uploaderFiles'>"
                str+="   </ul>"
                str+="   <div class='weui-uploader__input-box'>"
                str+="   <input id='uploaderInput' class='weui-uploader__input' type='file' accept='image/*'/>"
                str+="    </div>"
                str+="   </div>"

                str+="   </div>"
                str+="    </div>"
                str+="    <div class='weui-uploader__hd'style=' margin-top: 15%;'>"
                str+="   <a href='javascript:;' id='conf' class='weui-btn weui-btn_primary'>图片上传</a>"

                str+="   </div>"
                str+="    </div>"
                str+="   </div>"
        /*        str+="   <div id='img' >"
                str+="   <div class='weui-cell'>"
                str+="   <div class='weui-cell__bd'>"
                str+="    <div class='weui-uploader'>"
                str+="    <div class='weui-uploader__hd'>"
                str+="    <p class='weui-uploader__title'>上传头像</p>"
                str+="   </div>"*/
                $(".weui-cells").prepend(str);
            }, error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.toast("获取用户信息失败，请检查网络", "forbidden");
            }
        });


        var tmpl = '<li class="weui-uploader__file" style="background-image:url(#url#)"></li>',
            $uploaderInput=$("#uploaderInput"), $uploaderFiles = $("#uploaderFiles");
        $uploaderInput.on("change",function (e) {

            var src, url = window.URL || window.webkitURL || window.mozURL, files = e.target.files;
            for (var i = 0, len = files.length; i < len; ++i) {
                var file = files[i];
                lrz(file,{width:640,quality:0.9},function(rst){
                    $("#imgs").val(rst.base64);
                    $("#imgsname").val(rst.origin.name);

                });
                if (url) {
                    src = url.createObjectURL(file);
                } else {
                    src = e.target.result;
                }
                if($uploaderFiles.find(".weui-uploader__file").length>0){
                    $uploaderFiles.find(".weui-uploader__file").css("background-image","url(" + src + ")");
                }else {
                    $uploaderFiles.append($(tmpl.replace('#url#', src)));
                }

            }

        })



        $("#conf").click(function(){

            if($("#imgsname").val()!=""&&$("#imgsname").val()!=null){
            $.ajax({
                type: "POST",
                url: 'productRelease/updatetouxiang',
                async: false,
                data: {
                    id:localStorage.getItem("token"),
                    imgs:$("#imgs").val(),
                    imgsname:$("#imgsname").val()
                },
                success: function (msg) {
                    if(msg ==true){
                        $.alert({
                            title: '提示',
                            text: '头像上传成功',
                            onOK: function () {
                                //点击确认
                                window.location.href = "user.html"
                            }
                        });

                }


                },
                error: function (returndata) {
                    $.hideLoading();
                    $.toast("上传失败，请检查网络或者联系管理员");
                }
            });
            }else{
                $.toast("请选择图片");
            }


        });
    });
    function isNull(str) {
        if(str==null||str==""||str=="undefined"){
            return '';
        }else{
            return str;
        }
    }
    function loginout() {
        $.confirm("确定要退出吗？", function() {
            localStorage.clear();
            setTimeout(function() {
                window.location.href="login.html";
            }, 1000);
        }, function() {
            //点击取消后的回调函数
        });


    }
</script>
<script src="js/web/checkLogin.js"></script>
</body>
</html>